-
-
Notifications
You must be signed in to change notification settings - Fork 650
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perf: async task execution for player SaveManager #3050
Open
dudantas
wants to merge
20
commits into
main
Choose a base branch
from
dudantas/improve-players-saving
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Co-Authored-By: Renato Machado <[email protected]>
dudantas
force-pushed
the
dudantas/improve-players-saving
branch
from
November 1, 2024 22:48
293eabd
to
2cef00f
Compare
dudantas
changed the title
perf: improve players saving
perf: async task execution for player SaveManager
Nov 2, 2024
Converted to miliseconds and set the "done_at" to unique key.
dudantas
force-pushed
the
dudantas/improve-players-saving
branch
from
November 2, 2024 03:13
219bb34
to
e8639c7
Compare
phacUFPE
requested changes
Nov 3, 2024
Iterating with "for" range based on phmap::flat_hash_map is very expensive.
dudantas
force-pushed
the
dudantas/improve-players-saving
branch
from
November 7, 2024 02:34
38e8a84
to
7f21324
Compare
dudantas
force-pushed
the
dudantas/improve-players-saving
branch
from
November 9, 2024 00:47
d4344ad
to
352d80d
Compare
Quality Gate passedIssues Measures |
This PR is stale because it has been open 45 days with no activity. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This implements a new approach for executing player-related save tasks asynchronously using a task-based model. The change allows for tasks to be stored in a vector and later executed as a batch, which reduces the load on the main game thread and improves the efficiency of player data persistence. Each task is added to the Save Manager as a lambda function, allowing flexibility for handling various save operations (e.g., player inventory, stash, storage). The solution aims to ensure that tasks are executed in the same order they were added, addressing the potential bottlenecks in high-load scenarios.
Replacement of
std::ostringstream
withfmt::format
in load/save functions:All instances of
std::ostringstream
were replaced byfmt::format
. This change results in several improvements:fmt::format
is generally faster and more efficient compared tostd::ostringstream
when constructing strings, especially in high-load scenarios.fmt::format
improves code readability, making string formatting more concise and reducing verbosity.fmt::format
reduces the risk of common errors that occur with multiple chained<<
operators, leading to more robust and maintainable code.Behaviour
Actual
Expected
Type of change
How Has This Been Tested
Checklist
Improvements in Player Storage, Stash, and Forge History
Summary of Changes:
Centralization into Separate Classes:
The functionalities related to player storage, stash, and forge history have been organized into individual classes under a new folder named "components." This separation enhances code maintainability and readability, ensuring each component is modular and well-defined.
Caching System for Modified Items Only:
A caching mechanism was introduced to only save information that has been modified. Instead of saving all data related to the player, the system tracks modified or removed keys/items, significantly improving save efficiency. This reduces redundant save operations and minimizes database load.
Unique Key for Forge History (
done_at
):For the Forge History system, a unique key (
done_at
) was added to ensure precise control over what needs to be saved. This modification allows for selective updates, meaning only records that were changed will be saved, leading to improved consistency and optimized performance when dealing with large data sets.These enhancements collectively contribute to improving the scalability and efficiency of the system, reducing the performance overhead caused by frequent save operations.